package spring.data.redis.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

@Repository
public class StudentRedisDao {

	@Autowired
	private RedisTemplate<String,Student> redisTemplate;

	public void save(Student Student) {
		/*redisTemplate.opsForList();
		redisTemplate.opsForSet();
		redisTemplate.opsForHash()*/
		ValueOperations<String, Student> valueOper = redisTemplate.opsForValue();
		valueOper.set(Student.getId(), Student);
	}

	public Student read(String id) {
		ValueOperations<String, Student> valueOper = redisTemplate.opsForValue();
		return valueOper.get(id);
	}

	public void delete(String id) {
		ValueOperations<String, Student> valueOper = redisTemplate.opsForValue();
		RedisOperations<String,Student>  RedisOperations  = valueOper.getOperations();
		RedisOperations.delete(id);
	}
}
